import request from '@/utils/request'
import { ObjectType, ResponseDataPromise } from 'typings/interfaces'
import * as proxy from '@/constants/proxy'
import { Pagination } from '@/components/Records/types'
export interface Params extends ObjectType {
  goodsType?: string
  goodsName?: string
}
export const fetchRecordsRequest = (
  pagination: Omit<Pagination, 'total'>,
  data: ObjectType
): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-traffic-safety-in-construction/page',
    method: 'post',
    data,
    params: pagination,
  })

export const createRecordRequest = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-traffic-safety-in-construction',
    method: 'post',
    data,
  })

  //根据id查询
  export const RecordRequest = (id: string): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-traffic-safety-in-construction/${id}`,
    method: 'get',
  })

export const editRecordRequest = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-traffic-safety-in-construction',
    method: 'put',
    data,
  })


export const deleteRecordsRequest = (ids: string[]) =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-traffic-safety-in-construction`,
    method: 'delete',
    data: ids,
  })


// export const exportRecordsRequest = (): ResponseDataPromise<ObjectType> =>
//   request({
//     url: proxy.CHECC_API_BASE_DATA + '/bd_traffic/export',
//     method: 'post',
//   })

export const importRecordsRequest = (): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-traffic-safety-in-construction/import',
    method: 'post',
  })

// // 交安概览信息
// export const annRecordsRequest = (
//   pagination: Omit<Pagination, 'total'>,
//   data: Params
// ): ResponseDataPromise<ObjectType> =>
//   request({
//     url: proxy.CHECC_API_BASE_DATA + '/bd-traffic-safety-in/overview',
//     method: 'post',
//     data,
//     params: Object.assign(pagination, data),
//   })
